<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>遍历</title>
    <script src="../UI/jquery/jquery-3.3.1.min.js"></script>
</head>
<body>
    <div>1</div>
    <div>2</div>
    <div>3</div>
    <script>
        $(function(){
            var sum =0;
            const arr=["red" ,"yellow" ,"blue"];
            $("div").each(function(index,domEle){
                //第一个参数可以自己定义名字，第二个参数是dom对象
                $(domEle).css("color",arr[index]);
                sum +=parseInt($(domEle).text());  
            });
            console.log(sum);

            $.each({
                name:"EMasker",
                age:20
            },function(i,ele){//第一个参数是属性值，第二个是属性名，可自定义
                console.log(i+":"+ele);
            })
        })
    </script>
</body>
</html>